﻿using System;
using System.Collections.Generic;
using System.Text;
using Castle.ActiveRecord;
using Castle.Components.Validator;
using Wolfut.MirageEE.Kernal.Common;

namespace Wolfut.MirageEE.Domain.Sales
{
    /// <summary>
    /// This object represents the properties and methods of a Customer.
    /// </summary>
    /// <remarks>
    /// Author: Leo
    /// Date: 2009-03-14
    /// </remarks>
    [ActiveRecord("CUSTOMERS")]
    public class Customer: PersistentObjectWithGuid
    {
        #region 客户编号
        private string customerCode = string.Empty;
        [Property("CUSTOMER_CODE")]
        [ValidateIsUnique("数据库已经存在相同的客户编号")]
        [ValidateNonEmpty, ValidateLength(0, 100, "客户编号超长！")]
        public virtual string CustomerCode
        {
            get
            {
                return customerCode;
            }
            set
            {
                customerCode = value;
            }
        }
        #endregion

        #region 客户类型
        private Int16 customerType;
        [Property("CUSTOMER_TYPE")]
        [ValidateIsUnique("数据库已经存在相同的客户类型")]
        public virtual Int16 CustomerType
        {
            get
            {
                return customerType;
            }
            set
            {
                customerType = value;
            }
        }
        #endregion

        #region 客户名称
        private string customerName = string.Empty;
        [Property("CUSTOMER_NAME")]
        [ValidateIsUnique("数据库已经存在相同的客户名称")]
        [ValidateNonEmpty, ValidateLength(0, 100, "客户名称超长！")]
        public virtual string CustomerName
        {
            get { return customerName; }
            set { customerName = value; }
        }
        #endregion

        #region 地区
        private string areaCode = string.Empty;
        [Property("AREA_CODE")]
        [ValidateNonEmpty, ValidateLength(0, 200, "客户名称超长！")]
        public virtual string AreaCode
        {
            get { return areaCode; }
            set { areaCode = value; }
        }
        #endregion

        #region 业务员
        private string principal = string.Empty;
        [Property]
        [ValidateIsUnique("数据库已经存在相同的业务员")]
        [ValidateNonEmpty, ValidateLength(0, 100, "业务员名称超长！")]
        public virtual string Principal
        {
            get { return principal; }
            set { principal = value; }
        }
        #endregion

        #region 客户类别
        private string customerCategory;
        [Property("CUSTOMER_CATEGORY")]
        [ValidateIsUnique("数据库已经存在相同的客户类别")]
        [ValidateNonEmpty, ValidateLength(0, 100, "客户类别超长！")]
        public virtual string CustomerCategory
        {
            get { return customerCategory; }
            set { customerCategory = value; }
        }
        #endregion

        #region 备注
        private string remarks = string.Empty;
        [Property]
        [ValidateNonEmpty, ValidateLength(0, 2000, "备注超长！")]
        public virtual string Remarks
        {
            get { return remarks; }
            set { remarks = value; }
        }
        #endregion

        #region 折扣率
        private decimal discountRate;
        [Property]
        public virtual decimal DiscountRate
        {
            get { return discountRate; }
            set { discountRate = value; }
        }
        #endregion

        #region 账期
        private short collectionPeriod;
        [Property("COLLECTION_PERIOD")]
        public virtual short CollectionPeriod
        {
            get { return collectionPeriod; }
            set { collectionPeriod = value; }
        }

        #endregion

        #region 信用额度
        private decimal credit;
        [Property]
        public virtual decimal Credit
        {
            get { return credit; }
            set { credit = value; }
        }
        #endregion

        #region 纳税识别号
        private string ratepayingIdentify = string.Empty;
        [Property("RATEPAYING_IDENTIFY")]
        [ValidateNonEmpty, ValidateLength(0, 50, "纳税识别号超长！")]
        public virtual string RatepayingIdentify
        {
            get { return ratepayingIdentify; }
            set { ratepayingIdentify = value; }
        }
        #endregion

        #region 开票类型
        private string billingType = string.Empty;
        [Property("BILLING_TYPE")]
        [ValidateNonEmpty, ValidateLength(0, 40, "开票类型超长！")]
        public virtual string BillingType
        {
            get { return billingType; }
            set { billingType = value; }
        }
        #endregion

        #region 开户银行
        private string bank = string.Empty;
        [Property]
        [ValidateNonEmpty, ValidateLength(0, 255, "开户银行超长！")]
        public virtual string Bank
        {
            get { return bank; }
            set { bank = value; }
        }
        #endregion

        #region 使用状态
        private Boolean usedState;
        [Property("USED_STATE")]
        public virtual Boolean UsedState
        {
            get { return usedState; }
            set { usedState = value; }
        }

        #endregion

        #region 客户来源
        private string customerSource = string.Empty;
        [Property("CUSTOMER_SOURCE")]
        [ValidateNonEmpty, ValidateLength(0, 100, "客户来源超长！")]
        public virtual string CustomerSource
        {
            get { return customerSource; }
            set { customerSource = value; }
        }
        #endregion

        #region 开户账号
        private string account = string.Empty;
        [Property]
        [ValidateNonEmpty, ValidateLength(0, 100, "开户账号超长！")]
        public virtual string Account
        {
            get { return account; }
            set { account = value; }
        }
        #endregion

        #region 是否删除
        private Boolean isDeleted;
        [Property("IS_DELETED")]
        public virtual Boolean IsDeleted
        {
            get { return isDeleted; }
            set { isDeleted = value; }
        }
        #endregion

    }
}
